#pragma once

#include "CoreMinimal.h"
#include "Widgets/SWindow.h"

DECLARE_LOG_CATEGORY_EXTERN(LogSMainWindow, Log, All)

DECLARE_DELEGATE_OneParam(FOnClipBoardStringChange,const FString&)

class SMainWindow : public SWindow
{
public:
	SLATE_BEGIN_ARGS(SMainWindow)
	{
	}
	SLATE_END_ARGS()

	SMainWindow();
	virtual	~SMainWindow();

	/** Widget constructor */
	void Construct(const FArguments& Args);
	void CustomTick();
	FOnClipBoardStringChange OnClipBoardStringChange;

protected:
	TSharedRef<SWidget> MakeMainMenu();
	TSharedPtr<class SContentView> ContentView;

	TSharedRef<class SDockTab> OnSpawnTab_SummaryView(const FSpawnTabArgs& Args);

	void OnExit(const TSharedRef<SWindow>& InWindow);
	void OnOpenAboutDialog();


	/**
	 * Called when the user is dropping something onto a widget; terminates drag and drop.
	 *
	 * @param MyGeometry      The geometry of the widget receiving the event.
	 * @param DragDropEvent   The drag and drop event.
	 *
	 * @return A reply that indicated whether this event was handled.
	 */
	virtual FReply OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent) override;

	/**
	 * Called during drag and drop when the the mouse is being dragged over a widget.
	 *
	 * @param MyGeometry      The geometry of the widget receiving the event.
	 * @param DragDropEvent   The drag and drop event.
	 *
	 * @return A reply that indicated whether this event was handled.
	 */
	virtual FReply OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)  override;

	/**
	 * Called after a key is released when this widget has focus
	 *
	 * @param MyGeometry The Geometry of the widget receiving the event
	 * @param InKeyEvent  Key event
	 * @return Returns whether the event was handled, along with other possible actions
	 */
	virtual FReply OnKeyUp(const FGeometry& MyGeometry, const FKeyEvent& InKeyEvent);

	void SaveConfig();
	void LoadConfig();

protected:
	static const int32 WINDOW_WIDTH = 900;
	static const int32 WINDOW_HEIGHT = 800;
	bool bInit = false;

	/** Holds the tab manager that manages the front-end's tabs. */
	TSharedPtr<class FTabManager> TabManager;

	FString PrePasteContent;
};
